imcontext: Fix cursor positions
authorMatthias Clasen <mclasen@redhat.com>
Wed, 21 Apr 2021 10:27:26 +0000 (06:27 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Wed, 21 Apr 2021 10:28:52 +0000 (06:28 -0400)
gtk_im_context_get_preedit_string is documented to
return the cursor position as a character offset,
not a byte count. So return that.

Fixed: #3885

gtk/gtkimcontextsimple.c

index a3a2c54c8f4306888ca3e194b6e5f48b602e5162..074ffdd01f98048f4bc2ec9a1796d24b575f8b14 100644 (file)
@@ -1152,7 +1152,7 @@ gtk_im_context_simple_get_preedit_string (GtkIMContext   *context,
     }
 
   if (cursor_pos)
-    *cursor_pos = s->len;
+    *cursor_pos = g_utf8_strlen (s->str, s->len);
 
   if (attrs)
     {